#ifndef __controls_h__
#define __controls_h__

#include "core.h"

namespace core
{



/*
 * @breif: image property name.
 */
extern const char * IMAGE_CONTROL_PROPERTY_SOURCE;





/*
 * @breif: grid image property name.
 */
extern const char * GRID_IMAGE_CONTROL_PROPERTY_LENGTH;
extern const char * GRID_IMAGE_CONTROL_PROPERTY_INDEX;
extern const char * GRID_IMAGE_CONTROL_PROPERTY_GRID;
extern const char * GRID_IMAGE_CONTROL_PROPERTY_LEFT;
extern const char * GRID_IMAGE_CONTROL_PROPERTY_TOP;
extern const char * GRID_IMAGE_CONTROL_PROPERTY_RIGHT;
extern const char * GRID_IMAGE_CONTROL_PROPERTY_BOTTOM;





/*
 * @breif: the div control.
 */
class FaceDivision : public FaceWindow
{
    DECLARE_DYNAMIC_CREATE(FaceDivision)
public:
    FaceDivision(){}
    ~FaceDivision(){}

private:
    DISABLE_COPY_AND_ASSIGN(FaceDivision)
};





/*
 * @breif: the span control.
 */
class FaceSpan : public FaceWindow
{
    DECLARE_DYNAMIC_CREATE(FaceSpan)
public:
    FaceSpan();

    virtual void Offset( int x, int y );

protected:
    BEGIN_MESSAGE_MAP()
        MESSAGE_HANDLE( FM_LOAD, OnLoad )
        MESSAGE_HANDLE( FM_LAYOUT, OnLayout )
        MESSAGE_HANDLE( FM_PAINT, OnPaint )
        CHAIN_MESSAGE_MAP(FaceWindow)
    END_MESSAGE_MAP()

    uint OnLoad( uint, uint );
    uint OnLayout( uint, uint );
    uint OnPaint( uint, uint );

protected:
    bool ParseInlineControls( const XmlElement *element, const FaceStyleManager *manager );

private:
    DISABLE_COPY_AND_ASSIGN(FaceSpan)
};





/*
 * @breif: the br control.
 */
class FaceBreak : public FaceWindow
{
    DECLARE_DYNAMIC_CREATE(FaceBreak)
public:
    FaceBreak();

    virtual bool IsNewLine(){ return true; }

protected:
    BEGIN_MESSAGE_MAP()
        MESSAGE_HANDLE( FM_LAYOUT, OnLayout )
        MESSAGE_HANDLE( FM_ADJUST, OnAdjust )
        MESSAGE_HANDLE( FM_PAINT,  OnPaint  )
        CHAIN_MESSAGE_MAP(FaceWindow)
    END_MESSAGE_MAP()

    uint OnLayout( uint, uint );
    uint OnAdjust( uint, uint );
    uint OnPaint( uint, uint );

private:
    DISABLE_COPY_AND_ASSIGN(FaceBreak)
};





/*
 * @breif: the button control.
 */
class FaceButton : public FaceWindow
{
    DECLARE_DYNAMIC_CREATE(FaceButton)
public:
    FaceButton(){}
    ~FaceButton(){}

private:
    DISABLE_COPY_AND_ASSIGN(FaceButton)
};





/*
 * @breif: the image control.
 */
class FaceImage : public FaceWindow
{
    DECLARE_DYNAMIC_CREATE(FaceImage)
public:
    FaceImage();

public:
    std::wstring file_;

public:
    DECLARE_ATTRIBUTE_MAP()

protected:
    BEGIN_MESSAGE_MAP()
        MESSAGE_HANDLE( FM_PAINT, OnPaint )
        CHAIN_MESSAGE_MAP(FaceWindow)
    END_MESSAGE_MAP()

    uint OnPaint( uint, uint );

private:
    DISABLE_COPY_AND_ASSIGN(FaceImage)
};





/*
 * @breif: the grid image control.
 */
class FaceGridImage : public FaceWindow
{
    DECLARE_DYNAMIC_CREATE(FaceGridImage)
public:
    FaceGridImage();

public:
    std::wstring file_;
    int          grid_length_;
    int          grid_index_;
    int          grid_top_;
    int          grid_left_;
    int          grid_bottom_;
    int          grid_right_;

protected:
    bool ParseGrid( const char * p );

public:
    DECLARE_ATTRIBUTE_MAP()

protected:
    BEGIN_MESSAGE_MAP()
        MESSAGE_HANDLE( FM_PAINT, OnPaint )
        CHAIN_MESSAGE_MAP(FaceWindow)
    END_MESSAGE_MAP()

    uint OnPaint( uint, uint );

private:
    DISABLE_COPY_AND_ASSIGN(FaceGridImage)
};





/*
 * @breif: the grid button control.
 */
class FaceGridButton : public FaceGridImage
{
    DECLARE_DYNAMIC_CREATE(FaceGridButton)
public:
    FaceGridButton();

protected:
    BEGIN_MESSAGE_MAP()
        MESSAGE_HANDLE( FM_MOUSEHOVER,      OnMouseHover  )
        MESSAGE_HANDLE( FM_MOUSELEAVE,      OnMouseLeave  )
        MESSAGE_HANDLE( FM_LBUTTONDOWN,     OnLButtonDown )
        MESSAGE_HANDLE( FM_LBUTTONUP,       OnLButtonUp   )
        CHAIN_MESSAGE_MAP(FaceGridImage)
    END_MESSAGE_MAP()

    uint OnMouseHover ( uint, uint );
    uint OnMouseLeave ( uint, uint );
    uint OnLButtonDown( uint, uint );
    uint OnLButtonUp  ( uint, uint );

private:
    DISABLE_COPY_AND_ASSIGN(FaceGridButton)
};



};
#endif